import pygame


class Heart:
    def __init__(self):
        self.x = 30
        self.y = 30
        self.image = pygame.transform.scale(pygame.image.load('heart.png'), (60, 50))

    def move(self):
        pressed = pygame.key.get_pressed()
        if pressed[pygame.K_UP]:
            self.y -= 3
        elif pressed[pygame.K_DOWN]:
            self.y += 3
        elif pressed[pygame.K_LEFT]:
            self.x -= 3
        elif pressed[pygame.K_RIGHT]:
            self.x += 3

    def render(self, screen):
        screen.blit(self.image, (self.x, self.y))


class Game:
    def __init__(self, img):
        pygame.init()
        self.screen = pygame.display.set_mode((400, 300))
        pygame.display.set_caption("my game")
        self.bg = (255, 255, 255)
        self.clock = pygame.time.Clock()
        self.game_over = False
        self.image = img

    def run(self):
        while not self.game_over:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    self.game_over = True
            self.screen.fill(self.bg)
            self.image.move()
            self.image.render(self.screen)
            pygame.display.update()
            self.clock.tick(60)


heart = Heart()
game = Game(heart)
game.run()